package com.water.camera

import androidx.appcompat.app.AppCompatDelegate
import com.snap.base.base.BaseApp
import com.snap.common.config.AdConfig
import com.snap.common.config.AppConfig
import com.snap.common.plugin.AppPlugin
import com.snap.util.spGetBoolean
import com.snap.wx.plugin.WXPlugin
import com.water.camera.activity.SplashAct
import com.water.camera.kt.AppConstant
import com.water.camera.kt.SpConstant

open class MyApp : BaseApp() {

    override fun onCreate() {
        super.onCreate()
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)

        // 如果给好评了，那么关闭所有广告
        AppConfig.ad.close = spGetBoolean(SpConstant.IS_GOOD, false)
    }

    override fun getSplash(): Class<*> {
        return SplashAct::class.java
    }

    override fun getHttpBaseUrl(): String {
        return AppConstant.APP_BASE_URL
    }

    override fun setAppConfig() {
        AppConfig.apply {
            privacy = BuildConfig.app_privacy
            agreement = BuildConfig.app_agreement
            channel = BuildConfig.CHANNEL
            appKey = AppConstant.APP_KEY
            umID = AppConstant.ID_UMENG
            debug = BuildConfig.DEBUG
            ad = AdConfig(
                appId = AppConstant.AD_APP_ID,
                appKey = AppConstant.AD_APP_KEY,
                splash = AppConstant.AD_SPLASH,
                insert = AppConstant.AD_INSERT,
                banner = AppConstant.AD_BANNER,
                reward = AppConstant.AD_REWARD,
                native = AppConstant.AD_NATIVE,
                checkLocal = false
            )
        }
    }

    override fun addPlugin(plugins: MutableList<AppPlugin>) {
        super.addPlugin(plugins)
        // 微信
        plugins.add(WXPlugin(AppConstant.ID_WECHAT_APP_ID, AppConstant.ID_WECHAT_SECRET))
    }
}